	$('#conuntlogin').click(function(){
	$('#bottom_log').css({'display':'block'});
	$('#conuntlogin').addClass('active_list');
	$('#bottom_wechat').css({'display':'none'});
	$('#wechatlogin').removeClass('active_list');
})
$('#wechatlogin').click(function(){
	$('#bottom_log').css({'display':'none'});
	$('#conuntlogin').removeClass('active_list');
	$('#bottom_wechat').css({'display':'block'});
	$('#wechatlogin').addClass('active_list');
});
//获取验证码
var onoff = false;
$('#getNum').click(function(){
	var inp = $('.phone').val();
	if(onoff){return false};
	onoff=true;
	if(inp == ''){
		$('#bottom_tip').html('请填写手机号码');
		Tipanimate();
	}else if(!(/^1(2|3|4|5|6|7|8|9)\d{9}$/.test(inp))){
		$('#bottom_tip').html('请填写正确手机号码');
		Tipanimate();
	}else{
		$.ajax({
			type:"POST",
			url: apiCollect.apiGetVerification,
			data:{
				username:inp
			},
			success:function(data){
				if(data.code=="000000"){
					var i = 61;
					var timer=setInterval(function(){
						i--;
						$('#getNum').html(i+'s');
						if(i==0){
							$('#getNum').html('获取短信验证码');
							clearInterval(timer);
						}
					},1000);
					onoff=false;
				}else{
					$('#bottom_tip').html(data.message);
					Tipanimate();
				}
			}
		});
	}

});
//下一步点击
$('#bottom_middle').click(function(){
	var inp = $('.phone').val();
	var num = $('#num').val();
	var sev = $('.severs').val();
	var pwdAgain = $('#userwordAgain input').val();

	if(inp ==''){
		$('#bottom_tip').html('请输入手机号码');
		Tipanimate();
	}else if(!(/^1(2|3|4|5|6|7|8|9)\d{9}$/.test(inp))){
		$('#bottom_tip').html('请输入正确手机号码');
		Tipanimate();
	}else if(num ==''){
		$('#bottom_tip').html('请输入验证码');
		Tipanimate();
	}else if(sev == ''){
		$('#bottom_tip').html('请填写密码');
		Tipanimate();
	}else if(pwdAgain == ''){
		$('#bottom_tip').html('密码不一致');
		Tipanimate();
	}
	else if(sev != pwdAgain){
		$('#bottom_tip').html('密码不一致');
		Tipanimate();
	}else{
		$.ajax({
			type:"POST",
			url: apiCollect.apiRegister,
			data:{
				username:inp,
				code:num,
				password:sev
			},
			success:function(data){
				if(data.code=='000000'){
					localStorage.setItem('wid', data.data.wid);
					window.location.href='regesitorMain.html';
				} else if (data.code == '990002') {
					$('#bottom_tip').html(data.message);
					Tipanimate();
					setTimeout(function () {
						window.location.href = './index.html';
					}, 1500);
				} else {
					$('#bottom_tip').html(data.message);
					Tipanimate()
				}
			}
		});
	}
})
function Tipanimate(){
	$('#bottom_tip').animate({'height':'40px'},200);
	$('#bottom_tip').delay(1000).animate({'height':'0px'},200,function(){$('#bottom_tip').html('');onoff=false;});
}

$('#wechatlogin').click(function(){
   var obj = new WxLogin({
          id:"bottom_wechat",
          appid: "wx888d26b22f4a7f28",
          scope: "snsapi_login",
          redirect_uri: encodeURI("http://www.soundems.com/head_for/logIn/regesitor.html"),
          state: '',
          style: "",
          href: "https://www.quxianchang.com/css/oss.css"
	});
})
function getQuery(name) {
	var url = location.search;
	var reg = new Object();
	if(url.indexOf('?') != -1) {
		var str = url.substr(1);
		var strs = str.split('&');
		for(var i = 0; i < strs.length; i++) {
			reg[strs[i].split('=')[0]] = unescape(strs[i].split('=')[1]);
		}
	}
	return reg;
}
var code = getQuery('code').code;
if(code){
	$.ajax({
		type:"POST",
		url: apiCollect.apiWXLogin,
		data:{
			wechatcode:code
		},
		success:function(data){
			if(data.code==000000){
				if(data.data.wechat==1){
					localStorage.setItem('wid', data.data.wid);
					window.location.href = 'wxregistor.html?headimgurl='+data.data.headimgurl;
				}else if(data.data.wechat==2){
					localStorage.setItem('wid', data.data.wid);
					window.location.href='regesitorMain.html';
				}else if(data.data.wechat==0){
					localStorage.setItem('token', data.data.token_key);
					localStorage.setItem('wid', data.data.wid);
					window.location.href='../index.html';
				}
			}else{
				console.log(data.message)
			}
		}
	});
}

$(document).on('keydown', function (ev) {
	if (ev.keyCode == 13) {
		$('#bottom_middle').trigger('click');
	}
})
